package com.example.firstopengl.programs;

import android.content.Context;
import android.opengl.GLES20;

import com.example.firstopengl.TextResourceReader;
import com.example.firstopengl.util.ShaderHelper;

/**
 * Created by liqian-ps on 2017/7/6.
 */

public class ShaderProgram {
    protected  static final String U_MATRIX = "u_Matrix";
    protected  static final String A_POSITION = "a_Position";
    protected  static final String A_TEXTURECOORDINATES = "a_TextureCoordinates";
    protected  static final String U_TEXTURE_UNIT = "u_TextureUnit";
    protected  static final String A_COLOR = "a_Color";


    protected  int programId;

    protected  ShaderProgram(Context context, int vertexShaderId, int fragmentShaderId){
        programId = ShaderHelper.buildProgram(TextResourceReader.readTextFileFromResource(context,vertexShaderId),
                TextResourceReader.readTextFileFromResource(context, fragmentShaderId));
    }

    public void useProgram(){
        GLES20.glUseProgram(programId);
    }
}
